﻿<%@ Page Title="" Language="C#" MasterPageFile="~/master/admin.master" AutoEventWireup="true" Inherits="Admin_admin_cms_listing" Codebehind="admin-cms-listing.aspx.cs" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<script src="<%= Utilities.SiteSettings.BaseUrl %>scripts/jquery.tmpl.js" type="text/javascript"></script>
	<link rel="stylesheet" href="<%= Utilities.SiteSettings.BaseUrl %>scripts/Grid/grid.css" />
    <script src="<%= Utilities.SiteSettings.BaseUrl %>scripts/Grid/pager.js"></script>
    <link rel="stylesheet" href="<%= Utilities.SiteSettings.BaseUrl %>scripts/Grid/loader.css" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<script type="text/javascript">

    function Filter() {
        currentPageIndex = 0;
        LoadPager();
        LoadData(0);
    }

    function LoadPager() {

        var serviceUrl = "../Services/SocialShare_Service.svc/SocailShare_Site_Contents/$count";
        var filterVal = $("#txtTitle").val();
        if (filterVal != "") {
            serviceUrl = "../Services/SocialShare_Service.svc/SocailShare_Site_Contents/$count/?$filter=substringof('" + filterVal + "',CmsTitle)";
        }

        $.ajax({
            type: "GET",
            url: serviceUrl,
            data: "{}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (data) {
                totalCount = data;
                SetPager(0);
            },
            error: function (msg) {
                alert(msg);
            }
        });
    }

    function LoadData(currentIndex) {

        var serviceUrl = "../Services/SocialShare_Service.svc/SocailShare_Site_Contents?" + "&$orderby=" + sortItem + " " + sortIDirection + "&$skip=" + (currentIndex * pageSize) + "&$top=" + pageSize;
        var filterVal = $("#txtTitle").val();
        if (filterVal != "") {
            serviceUrl = "../Services/SocialShare_Service.svc/SocailShare_Site_Contents?$filter=substringof('" + filterVal + "',CmsTitle)" + "&$orderby=" + sortItem + " " + sortIDirection + "&$skip=" + (currentIndex * pageSize) + "&$top=" + pageSize;
        }

        $.ajax({
            type: "GET",
            url: serviceUrl,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            beforeSend: function () { $("#wait").show(); },
            complete: function () { $("#wait").hide(); },
            success: function (data) {
                localDevelopers = data.d;
                $("#users").html("");
                $.each(data.d, function (i, item) {
                    var col1 = $("<td class='ui-state-custom-default'>").append(item.CmsId).append("</td>");
                    var col2 = $("<td class='ui-state-custom-default'>").append(item.CmsType).append("</td>");
                    var col3 = $("<td class='ui-state-custom-default'>").append(item.CmsTitle).append("</td>");
                    var col4 = $("<td class='ui-state-custom-default'>").append("<a href='admin-cms.aspx?CmsId=" + item.CmsId + "'>view</a>").append("</td>");

                    $("<tr class='ui-state-custom-default'>").append(col1).append(col2).append(col3).append(col4).append("</tr>").appendTo("#users"); ;

                });
                $('#dataTable tbody tr:even').addClass('grid-normal');
                $('#dataTable tbody tr:odd').addClass('grid-alternate');

            },
            error: function (msg) {
                alert(msg);
            }
        });
    }
        
    </script>
    <section class="grid_12 clearfix omega">
<section class="grid_12 clearfix omega">
<section id="wait" class="progress grid_5">
  <section class="progress-container">
        <section class="progress-header">Loading, please wait...</section>
        <section class="progress-body">
            <img src="../Scripts/Grid/pre-loader.gif" />
        </section>
    </section>
  
  </section>
  <section class="grid_7">
  &nbsp;
  </section>
</section>
<section class="grid_12 omega">
<fieldset>
<legend class="title-regular">Filter</legend>
    <input id="txtTitle" type="text"  placeholder="title" /><input id="btnFilter" type="button" value="serach" class="button small red" onclick="javascript:Filter();return false;" />
    </fieldset>
<table id="dataTable" width="100%" class="ui-custom-grid">
<caption>Site Contents</caption>
  <thead>
    <tr class="ui-state-custom-default">
      <th sort-data="CmsId" class="grid-header-asc">ID#</th>
      <th sort-data="CmsType" class="grid-header-asc">Type</th>
      <th sort-data="CmsTitle" class="grid-header-asc">Title</th>
      <th></th>
      
    </tr>
  </thead>
  <tbody id="users" >
  </tbody>
  <tfoot>
  <tr> <th align="center" colspan="4">
  
   <section class="grid_10 clearfix grid-pager">
   <a href="" class="button small blue pager-first" data-page="first">First</a>
    <a href="" class="button small green pager-prev" data-page="prev">Prev</a>	
	<span>
		Page <span class="current"></span>/<span class="total">0</span>,
		Total records <span class="totalRecords">0</span>
	</span>
	<a href=""  class="button small green pager-next" data-page="next">Next</a>
	<a href=""  class="button small blue pager-last" data-page="last">Last</a>
</section>
  </th>
  
  </tr>
 
  </tfoot>
</table>
</section>
</section>

</asp:Content>
